#include <iostream>
#include "time.h"
Time::Time()
{
    hours=0;
    minutes=0;
}
Time::Time(int h, int m)
{
    hours=h;
    minutes=m;
}
void Time::AddMin(int m)
{
    int total=minutes+m;
    hours+=total/60;
    minutes=total%60;
}
void Time::AddHr(int h)
{
    hours+=h;
}
void Time::Reset(int h, int m)
{
    hours=h;
    minutes=m;
}

Time Time::operator +(Time &t)
{
    Time sum;
    int tt=minutes+t.minutes;
    if(tt>=60) {sum.minutes=tt-60; sum.hours=hours+t.hours-1;}
    else 
    {
        sum.minutes=tt; sum.hours=hours+t.hours;
    }
    return sum;
}
Time Time::operator -(Time &t)
{
    Time diff;
    int tot1, tot2;
    tot1=t.minutes+60*t.hours;
    tot2=minutes+60*hours;
    diff.minutes=(tot2-tot1)%60;
    diff.hours=(tot2-tot1)/60;
    return diff;
}
Time Time::operator *(double mult)
{
    Time res;
    long totalminutes = hours * mult * 60 + minutes * mult;
    res.hours = totalminutes / 60;
    res.minutes = totalminutes % 60;
    return res;
}
std::ostream &operator <<(std::ostream &os, Time &t)
{
    os << t.hours << " hours, " << t.minutes << " minutes";
    return os;
}
